home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 051-060 / amok52 / abitur / txt / menus.mod < prev    next >
Text File  |  1993-11-04  |  11KB  |  442 lines

  1. IMPLEMENTATION MODULE Menus;
  2.  
  3. FROM AbiturScreen IMPORT BACKWindow;
  4. FROM Globals IMPORT AnzahlSpieler, AlleSpieler, Spieler, SpielerPtr;
  5. FROM SYSTEM IMPORT CAST, ADR, LONGSET, BITSET;
  6. FROM Intuition IMPORT Menu, MenuItem, MenuItemPtr, MenuItemFlagSet,
  7.                       MenuItemFlags, SetMenuStrip, ClearMenuStrip,
  8.                       IntuiText, IntuiTextPtr, OnMenu, menuEnabled;
  9. FROM FaecherNamen IMPORT FaecherTypen, FaecherNamen;
  10. FROM Exec IMPORT AllocMem, FreeMem, MemReqSet, MemReqs;
  11. FROM Arts IMPORT Assert, TermProcedure, BreakPoint;
  12. FROM Graphics IMPORT DrawModeSet;
  13. FROM Str IMPORT Copy;
  14.  
  15.  
  16. (* DEBUG *)
  17. (* FROM InOut IMPORT WriteString, WriteLn;  *)
  18.  
  19.  
  20.  
  21.  
  22.  
  23. VAR Menu0, Menu1, Menu2, Menu3: Menu;
  24.     SaveItem, LoadItem, NewItem, EndeItem, CHItem: MenuItem;
  25.     JahrItem: ARRAY[1..4] OF MenuItem;
  26.     FachItem: ARRAY[Turnen..Informatik] OF MenuItem;
  27.     Dummy : BOOLEAN;
  28.  
  29.     Menu0Text, Menu1Text, Menu2Text, Menu3Text,
  30.     SaveItemText, LoadItemText, NewItemText, EndeItemText,
  31.                   CHItemText, ItemText: IntuiText;
  32.     JahrItemText: ARRAY[1..4] OF IntuiText;
  33.     JahrName: ARRAY[1..4] OF ARRAY[0..20] OF CHAR;
  34.     FachItemText: ARRAY[Turnen..Informatik] OF IntuiText;
  35.  
  36.     SpielerIntuiTextPtr: IntuiTextPtr;
  37.      (* Jeder Spieler hat für seinen Namen einen IntuiText *)
  38.  
  39.  
  40.  
  41.  
  42. PROCEDURE FreeMenu0FromWindow;
  43. BEGIN
  44.    ClearMenuStrip(BACKWindow);
  45.    BACKWindow^.menuStrip := NIL
  46. END FreeMenu0FromWindow;
  47.  
  48.  
  49.  
  50.  
  51.  
  52. PROCEDURE FreeSpielerItems;
  53. VAR Temp : MenuItemPtr;
  54.     ITmp : IntuiTextPtr;
  55. BEGIN
  56.    WHILE Menu3.firstItem # NIL DO
  57.       Temp := Menu3.firstItem;
  58.       Menu3.firstItem := Menu3.firstItem^.nextItem;
  59.       FreeMem(Temp, SIZE(MenuItem));
  60.    END;
  61.    WHILE SpielerIntuiTextPtr # NIL DO
  62.       ITmp := SpielerIntuiTextPtr;
  63.       SpielerIntuiTextPtr := SpielerIntuiTextPtr^.nextText;
  64.       FreeMem(ITmp, SIZE(IntuiText))
  65.    END
  66. END FreeSpielerItems;
  67.  
  68.  
  69.  
  70. PROCEDURE AppendSpielerItem(VAR Name: ARRAY OF CHAR; i:INTEGER);
  71.  (* i: 1... *)
  72. VAR j : INTEGER;
  73.     t, TempPtr: MenuItemPtr;
  74.     d, TempITextPtr: IntuiTextPtr;
  75. BEGIN
  76.    TempPtr := AllocMem(SIZE(MenuItem), MemReqSet{public});
  77.    Assert(TempPtr#NIL, ADR("Not enough memory"));
  78.    TempITextPtr := AllocMem(SIZE(IntuiText), MemReqSet{public});
  79.    IF TempITextPtr = NIL THEN
  80.       FreeMem(TempPtr, SIZE(MenuItem));
  81.       Assert(FALSE, ADR("Not enough Mem"))
  82.    END;
  83.    WITH TempPtr^ DO
  84.       nextItem := NIL;
  85.       leftEdge := 0;
  86.       topEdge := 10*i - 10;
  87.       width := 120;
  88.       height := 10;
  89.       flags := MenuItemFlagSet{itemText, itemEnabled, highComp};
  90.       mutualExclude := LONGSET{};
  91.       itemFill := NIL;
  92.       selectFill := NIL;
  93.       command := 0C;
  94.       subItem := NIL;
  95.       nextSelect := 0
  96.    END;
  97.    WITH TempITextPtr^ DO
  98.       frontPen := 4;
  99.       backPen := 5;
  100.       drawMode := DrawModeSet{};
  101.       leftEdge := 0;
  102.       topEdge := i * 10 -9; (* (AnzahlSpieler - i) * 10  - 10 *)
  103.       iTextFont := NIL;
  104.       iText := ADR(Name); (* Sollte gehen, da VAR Parameter *)
  105.       nextText := NIL
  106.    END;
  107.    IF i = 1 THEN
  108.       Menu3.firstItem := TempPtr;
  109.       SpielerIntuiTextPtr := TempITextPtr;
  110.    ELSIF i = 2 THEN
  111.       Menu3.firstItem^.nextItem := TempPtr;
  112.       SpielerIntuiTextPtr^.nextText := TempITextPtr;
  113.    ELSE
  114.       t := Menu3.firstItem;
  115.       d := SpielerIntuiTextPtr;
  116.       FOR j := 1 TO i - 2 DO
  117.          t := t^.nextItem;
  118.          d := d^.nextText
  119.       END;
  120.       t^.nextItem := TempPtr;
  121.       d^.nextText := TempITextPtr
  122.    END
  123. END AppendSpielerItem;
  124.  
  125.  
  126.  
  127. PROCEDURE RefreshSpielerMenu(): BOOLEAN;
  128. VAR i: INTEGER;
  129.     AktSp: SpielerPtr;
  130. BEGIN
  131.    FreeSpielerItems;
  132.    IF AnzahlSpieler > 20 THEN RETURN FALSE END;
  133.    IF AnzahlSpieler <=0  THEN RETURN TRUE END;
  134.  
  135.    ClearMenuStrip(BACKWindow);
  136.     AktSp:=AlleSpieler;
  137.     FOR i := 1 TO AnzahlSpieler DO
  138.        AppendSpielerItem(AktSp^.Name, i);
  139.        AktSp := AktSp^.Next
  140.     END;
  141.  
  142.     Menu3.firstItem^.itemFill := SpielerIntuiTextPtr;
  143.  
  144.    IF SetMenuStrip(BACKWindow, ADR(Menu0)) THEN END;
  145.  
  146.    (* OnMenu(BACKWindow, 0); *)
  147.    RETURN TRUE
  148. END RefreshSpielerMenu;
  149.  
  150.  
  151.  
  152. PROCEDURE CH():BOOLEAN;
  153. BEGIN
  154.    RETURN checked IN CHItem.flags
  155. END CH;
  156.  
  157.  
  158.  
  159. VAR i: INTEGER;
  160.     F: FaecherTypen;
  161. BEGIN (* Menus Initialisierung *)
  162.  
  163.  
  164.  (*********************************)
  165.  (***** M E N U   0   Install *****)
  166.  (*********************************)
  167.  
  168.    WITH Menu0 DO
  169.       nextMenu  := ADR(Menu1);
  170.       leftEdge  := 0;
  171.       topEdge   := 0;
  172.       width     := 48;
  173.       height    := 10;
  174.       flags     := BITSET{menuEnabled};
  175.       menuName  := ADR("GAME");
  176.       firstItem := ADR(SaveItem);
  177.       jazzX     := 0;
  178.       jazzY     := 0;
  179.       beatX     := 0;
  180.       beatY     := 0
  181.    END;
  182.    WITH SaveItemText DO
  183.       frontPen := 3;
  184.       backPen := 6;
  185.       drawMode := DrawModeSet{};
  186.       leftEdge := 0;
  187.       topEdge := 1;
  188.       iTextFont := NIL;
  189.       iText := ADR("SAVE");
  190.       nextText := NIL
  191.    END;
  192.    WITH SaveItem DO
  193.       nextItem := ADR(LoadItem);
  194.       leftEdge := 0;
  195.       topEdge  := 0;
  196.       width := 80;
  197.       height := 10;
  198.       flags := MenuItemFlagSet{itemText, commSeq, itemEnabled, highComp};
  199.       mutualExclude := LONGSET{};
  200.       itemFill := ADR(SaveItemText);
  201.       selectFill := NIL;
  202.       command := "S";
  203.       subItem := NIL;
  204.       nextSelect := 0
  205.    END;
  206.    WITH LoadItemText DO
  207.       frontPen := 3;
  208.       backPen := 6;
  209.       drawMode := DrawModeSet{};
  210.       leftEdge := 0;
  211.       topEdge := 1;
  212.       iTextFont := NIL;
  213.       iText := ADR("LOAD");
  214.       nextText := NIL
  215.    END;
  216.    WITH LoadItem DO
  217.       nextItem := ADR(NewItem);
  218.       leftEdge := 0;
  219.       topEdge  := 10;
  220.       width := 80;
  221.       height := 10;
  222.       flags := MenuItemFlagSet{itemText, commSeq, itemEnabled, highComp};
  223.       mutualExclude := LONGSET{};
  224.       itemFill := ADR(LoadItemText);
  225.       selectFill := NIL;
  226.       command := "L";
  227.       subItem := NIL;
  228.       nextSelect := 0
  229.    END;
  230.    WITH NewItemText DO
  231.       frontPen := 3;
  232.       backPen := 6;
  233.       drawMode := DrawModeSet{};
  234.       leftEdge := 0;
  235.       topEdge := 1;
  236.       iTextFont := NIL;
  237.       iText := ADR("NEU ");
  238.       nextText := NIL
  239.    END;
  240.    WITH NewItem DO
  241.       nextItem := ADR(EndeItem);
  242.       leftEdge := 0;
  243.       topEdge  := 20;
  244.       width := 80;
  245.       height := 10;
  246.       flags := MenuItemFlagSet{itemText, commSeq, itemEnabled, highComp};
  247.       mutualExclude := LONGSET{};
  248.       itemFill := ADR(NewItemText);
  249.       selectFill := NIL;
  250.       command := "N";
  251.       subItem := NIL;
  252.       nextSelect := 0
  253.    END;
  254.    WITH EndeItemText DO
  255.       frontPen := 3;
  256.       backPen := 6;
  257.       drawMode := DrawModeSet{};
  258.       leftEdge := 0;
  259.       topEdge := 1;
  260.       iTextFont := NIL;
  261.       iText := ADR("ENDE");
  262.       nextText := NIL
  263.    END;
  264.    WITH EndeItem DO
  265.       nextItem := ADR(CHItem);
  266.       leftEdge := 0;
  267.       topEdge  := 30;
  268.       width := 80;
  269.       height := 10;
  270.       flags := MenuItemFlagSet{itemText, commSeq, itemEnabled, highComp};
  271.       mutualExclude := LONGSET{};
  272.       itemFill := ADR(EndeItemText);
  273.       selectFill := NIL;
  274.       command := "E";
  275.       subItem := NIL;
  276.       nextSelect := 0
  277.    END;
  278.    WITH CHItemText DO
  279.       frontPen := 3;
  280.       backPen := 6;
  281.       drawMode := DrawModeSet{};
  282.       leftEdge := 0;
  283.       topEdge := 1;
  284.       iTextFont := NIL;
  285.       iText := ADR("  CH");
  286.       nextText := NIL
  287.    END;
  288.    WITH CHItem DO
  289.       nextItem := NIL;
  290.       leftEdge := 0;
  291.       topEdge  := 40;
  292.       width := 80;
  293.       height := 10;
  294.       flags := MenuItemFlagSet{checkIt,menuToggle,itemText, commSeq,
  295.                                itemEnabled, highComp};
  296.       mutualExclude := LONGSET{};
  297.       itemFill := ADR(CHItemText);
  298.       selectFill := NIL;
  299.       command := "C";
  300.       subItem := NIL;
  301.       nextSelect := 0
  302.    END;
  303.  
  304.  
  305.  (*********************************)
  306.  (***** M E N U   1   Install *****)
  307.  (*********************************)
  308.  
  309.  
  310.  
  311.    WITH Menu1 DO
  312.       nextMenu := ADR(Menu2);
  313.       leftEdge := 50;
  314.       topEdge := 0;
  315.       width := 48;
  316.       height := 10;
  317.       flags := BITSET{menuEnabled};
  318.       menuName := ADR("Pläne");
  319.       firstItem := ADR(JahrItem[1]);
  320.       jazzX := 0;
  321.       jazzY := 0;
  322.       beatX := 0;
  323.       beatY := 0
  324.    END;
  325.    FOR i := 1 TO 4 DO
  326.       Copy(JahrName[i], " . Jahr");
  327.       JahrName[i][0] := CHR(i + ORD("0"));
  328.       WITH JahrItemText[i]  DO
  329.          frontPen := 3;
  330.          backPen := 6;
  331.          drawMode := DrawModeSet{};
  332.          leftEdge := 0;
  333.          topEdge := 1;
  334.          iTextFont := NIL;
  335.          iText := ADR(JahrName[i]);
  336.          nextText := NIL
  337.       END;
  338.       WITH JahrItem[i] DO
  339.          IF i = 4 THEN
  340.             nextItem := NIL
  341.          ELSE
  342.             nextItem := ADR(JahrItem[i+1])
  343.          END;
  344.          leftEdge := 0;
  345.          topEdge  := i*10-10;
  346.          width := 100;
  347.          height := 10;
  348.          flags := MenuItemFlagSet{itemText, commSeq, itemEnabled, highComp};
  349.          mutualExclude := LONGSET{};
  350.          itemFill := ADR(JahrItemText[i]);
  351.          selectFill := NIL;
  352.          command := CHR(ORD("0") + i);
  353.          subItem := NIL;
  354.          nextSelect := 0
  355.       END
  356.    END;
  357.  
  358.  
  359.  (*********************************)
  360.  (***** M E N U   2   Install *****)
  361.  (*********************************)
  362.  
  363.    WITH Menu2 DO
  364.       nextMenu := ADR(Menu3);
  365.       leftEdge := 100;
  366.       topEdge := 0;
  367.       width := 48;
  368.       height := 10;
  369.       flags := BITSET{menuEnabled};
  370.       menuName := ADR("Fach");
  371.       firstItem := ADR(FachItem[Turnen]);
  372.       jazzX := 0;
  373.       jazzY := 0;
  374.       beatX := 0;
  375.       beatY := 0
  376.    END;
  377.    FOR F := Turnen TO Informatik DO
  378.       WITH FachItemText[F]  DO
  379.          frontPen  := 3;
  380.          backPen   := 6;
  381.          drawMode  := DrawModeSet{};
  382.          leftEdge  := 0;
  383.          topEdge   := 1;
  384.          iTextFont := NIL;
  385.          iText     := ADR(FaecherNamen[F].VollName);
  386.          nextText  := NIL
  387.       END;
  388.       WITH FachItem[F] DO
  389.          IF F = Informatik THEN
  390.             nextItem := NIL
  391.          ELSE
  392.             INC(F);
  393.             nextItem := ADR(FachItem[F]);
  394.             DEC(F)
  395.          END;
  396.          leftEdge := 0;
  397.          topEdge  := ORD(F)*10;
  398.          width := 120;
  399.          height := 10;
  400.          flags := MenuItemFlagSet{itemText, itemEnabled, highComp};
  401.          mutualExclude := LONGSET{};
  402.          itemFill := ADR(FachItemText[F]);
  403.          selectFill := NIL;
  404.          command := 0C;
  405.          subItem := NIL;
  406.          nextSelect := 0
  407.       END
  408.    END;
  409.  
  410.  (*********************************)
  411.  (***** M E N U   3   Install *****)
  412.  (*********************************)
  413.  
  414.  
  415.    WITH Menu3 DO
  416.       nextMenu := NIL;
  417.       leftEdge := 150;
  418.       topEdge := 0;
  419.       width := 58;
  420.       height := 10;
  421.       flags := BITSET{menuEnabled};
  422.       menuName := ADR("Zeugnis");
  423.       firstItem := NIL;
  424.       jazzX := 0;
  425.       jazzY := 0;
  426.       beatX := 0;
  427.       beatY := 0
  428.    END;
  429.  
  430.    SpielerIntuiTextPtr := NIL;
  431.  
  432.    (* BreakPoint(ADR("In Menus vor SetMenuStrip")); *)
  433.    IF SetMenuStrip(BACKWindow, ADR(Menu0)) THEN
  434.    END;
  435.    (* OnMenu(BACKWindow, 0); *)
  436.  
  437.    TermProcedure(FreeSpielerItems);
  438.    TermProcedure(FreeMenu0FromWindow)
  439.  
  440. END Menus.
  441.  
  442.